<?php
if ($id) {
	$query = "select * from `usertheme` where `user`='$id'";
	$result = mysql_query($query);
	if (mysql_num_rows($result)){
		if ($_REQUEST['saveusertheme']){
			$colour1 = escapestr($_REQUEST['colour1']);
			$colour2 = escapestr($_REQUEST['colour2']);
			$colour3 = escapestr($_REQUEST['colour3']);
			$query = "UPDATE usertheme set 	`colour1`='$colour1',
											`colour2`='$colour2',
											`colour3`='$colour3'
									where `user`='$id'";
			$result = mysql_query($query);			
			if (!$result) die($query);
			
		} else {
			$usertheme = mysql_fetch_array($result);
			$colour1= $usertheme['colour1'];
			$colour2= $usertheme['colour2'];
			$colour3= $usertheme['colour3'];
		}	
	} else {
		if ($_REQUEST['saveusertheme']){
			$colour1 = escapestr($_REQUEST['colour1']);
			$colour2 = escapestr($_REQUEST['colour2']);
			$colour3 = escapestr($_REQUEST['colour3']);
			$query = "INSERT INTO usertheme (`user`,`colour1`,`colour2`,`colour3`) values ('$id','$colour1','$colour2','$colour3')";
			$result = mysql_query($query);	
			if (!$result) die($query);
		}
	}
} 


$example = "
<style>
#examplebox {
	width:75%; 
	height:100px; 
	border: 3px dashed $colour1;
	padding:12px;
	margin:12px;
	font-family: sans-serif; 
	}

#examplebox, #exampletext	{
	background-color: $colour2 ; 
	color: $colour3;
	font-family: sans-serif; 

}
#exampleheader{
	background-color: $colour3; 
	color: $colour2;
	font-family: sans-serif; 
	margin-bottom:6px;
}
</style>
<div   id=examplebox>
	<div id=exampleheader>
	".GetLangString($lang,"txt_example")."
	</div>
	<div id=exampletst align=left>
	".GetLangString($lang,"msg_example")."
	</div>
</div>";
if (!$RENDER_MOBILE) $SITE_MIDDLE .= "<table width=100%><tr><td width=50% align=center valign=top>";
$SITE_MIDDLE .= FormatElement(GetLangString($lang,"txt_userthemepreview"),$example);
if (!$RENDER_MOBILE) $SITE_MIDDLE .= "</td><td valign=top>";
$SITE_MIDDLE .= FormatElement(GetLangString($lang,"txt_userthemesettings"),
	"<center><div style='width:75%;'><form method=post action='index.php?do=usertheme'>".
		GetLangString($lang,"txt_colour")." 1<input name=colour1 value=$colour1><br>".
		GetLangString($lang,"txt_colour")." 2<input name=colour2 value=$colour2><br>".
		GetLangString($lang,"txt_colour")." 3<input name=colour3 value=$colour3><br>
	<input type=submit name=saveusertheme value='".GetLangString($lang,"txt_save")."'></form></div></center>");
if (!$RENDER_MOBILE) $SITE_MIDDLE .= "</td></tr></table>";
?>